package view;


import java.awt.Component;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import javax.swing.JTextField;
import java.awt.FlowLayout;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;

public class CourseNameCellRender extends JPanel implements TableCellRenderer {
	private static final long serialVersionUID = -30412102324531068L;
	private JTextField textField;
    public CourseNameCellRender()   {
    	
    	textField = new JTextField();
    	textField.setColumns(10);
    	
    	JButton btnDetails = new JButton("Details ...");
    	btnDetails.addActionListener(new ActionListener() {
    		public void actionPerformed(ActionEvent arg0) {
    			
    		}
    	});
    	GroupLayout groupLayout = new GroupLayout(this);
    	groupLayout.setHorizontalGroup(
    		groupLayout.createParallelGroup(Alignment.LEADING)
    			.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
    				.addGap(5)
    				.addComponent(textField, GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE)
    				.addPreferredGap(ComponentPlacement.RELATED)
    				.addComponent(btnDetails)
    				.addContainerGap())
    	);
    	groupLayout.setVerticalGroup(
    		groupLayout.createParallelGroup(Alignment.LEADING)
    			.addGroup(groupLayout.createSequentialGroup()
    				.addGap(5)
    				.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
    					.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    					.addComponent(btnDetails))
    				.addGap(1))
    	);
    	setLayout(groupLayout);
    	//setIcon(new ImageIcon(StartScreen.class.getResource("/resources/date-icon.png")));
    }
	
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		// TODO Auto-generated method stub
		//System.out.println(value);
		textField.setText((String) value);
        return this;

	}

}
